 package com.briup.cms.web.controller;



 import com.briup.cms.bean.Comment;
 import com.briup.cms.service.ICommentService;
 import com.briup.cms.utils.Message;
 import com.briup.cms.utils.MessageUtil;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

 @Api(tags = {"评论管理"})
 @RestController
 @RequestMapping({"/auth/comment"})
 public class CommentController
{
  @Autowired
  private ICommentService commentService;

   @ApiOperation("分页所有评论信息")
  @ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"), @ApiImplicitParam(name = "keywords", value = "评论关键字", paramType = "query")})
   @GetMapping({"/pageQuery"})
 public Message pageQuery(int pageNum, int pageSize, String keywords) {
     PageInfo<Comment> data = this.commentService.pageQuery(pageNum, pageSize, keywords);
    return MessageUtil.success(data);
  }

  @ApiOperation("批量删除评论")
   @DeleteMapping({"/batchDelete"})
   public Message batchDelete(int[] ids) {
    this.commentService.batchDelete(ids);
     return MessageUtil.success("删除成功");
   }

   @ApiOperation("根据ID删除评论")
   @DeleteMapping({"/deleteById"})
   public Message deleteById(int id) {
    this.commentService.deleteById(id);
    return MessageUtil.success("删除成功");
  }

  @ApiOperation(value = "审核评论", notes = "status状态：0-待审核，1-不通过，2-通过")
  @PutMapping({"/check"})
  public Message check(int id, int status) {
    this.commentService.checkComment(id, status);
   return MessageUtil.success("操作成功");
 }
}


